package com.chinasoft.exam.mapper;

import com.chinasoft.exam.pojo.Brand;
import org.apache.ibatis.annotations.*;

import java.util.List;
import java.util.Map;

public interface BrandMapper {

    @Select("select * from tb_brand where id=#{id}")
    Brand selectById(Integer id);
    @Select(" select * from tb_brand")
    List<Brand> selectAll();
    @Select(" select * from tb_brand where brand_name like '%${name}%'")
    List<Brand> selectLike(String name);
    @Select(" select * from tb_brand where\n" +
            "        status = #{status}\n" +
            "        and company_name like #{companyName}\n" +
            "        and brand_name like #{brandName}")
    List<Brand> selectByCondition(Brand brand);

//    List<Brand> selectByCondition(Map map);
//    List<Brand> selectByCondition(@Param("status") Integer status,
//                                  @Param("companyName") String companyName,
//                                  @Param("brandName") String brandName
//                                  );
    // 使用动态sql进行多条件查询，支持模糊查询， 使用 ${}

//    List<Brand> selectByDSql(Brand brand);
    // insert 一条记录
    @Insert(" insert into tb_brand(id, brand_name, company_name,\n" +
            "        ordered, description, status ) values\n" +
            "        (null, #{brandName}, #{companyName}, #{ordered}, #{description}, #{status})")
    int insert1(Brand brand);
    @Update(" update tb_brand set\n" +
            "            brand_name = #{brandName},\n" +
            "            company_name = #{companyName},\n" +
            "            ordered = #{ordered},\n" +
            "            description = #{description},\n" +
            "            status = #{status}\n" +
            "        where id = #{id}")
    int update1(Brand brand);
    // 删除一条记录
    @Delete("delete  from tb_brand where id = #{id}")
    int delete1(Integer id);
    // 批量删除 记录
//    int deleteBatch(@Param("ids") List<Integer> ids);
//    @Delete(" delete from tb_brand where id in()")
//    int deleteBatch(@Param("ids") int[] idList);
}
